//
//  WCMokeListViewController.m
//  WeChatBuniess
//
//  Created by Guo Rui on 2017/12/26.
//  Copyright © 2017年 GR Harry. All rights reserved.
//

#import "WCMokeListViewController.h"
#import "WCAAutoMakeBookManager.h"
#import "WCAListOperateViewController.h"
#import "WCBDataSourceGenerator.h"
#import "TFDataCaptureManager.h"

@interface WCMokeListViewController ()<WCBDataSourceGeneratorDelegate>
@property (nonatomic, strong) WCBDataSourceGenerator   *dataSourceGenerator;
@end

@implementation WCMokeListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor yellowColor];
    self.title = @"朋友圈";
    
    self.dataSourceGenerator = [WCBDataSourceGenerator sharedInstance];
    self.dataSourceGenerator.delegate = self;
    [self.dataSourceGenerator begin];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        WCAListOperateViewController *vc = [[WCAListOperateViewController alloc] init];
        vc.contact = self.contact;
        UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
        [self presentViewController:nvc animated:YES completion:nil];
        
        __weak WCMokeListViewController *_self = self;
        vc.completion = ^{
            [_self dismissViewControllerAnimated:YES completion:nil];
        };
    });
}
- (void)dealloc {
    NSLog(@"\n************\n %@ dealloc \n************", self.class);
}

//MARK: - WCBDataSourceGeneratorDelegate
- (void)generateDataWithItems:(NSArray<WCDataItem *> *)dataItems {
    [dataItems enumerateObjectsUsingBlock:^(WCDataItem * _Nonnull item, NSUInteger idx, BOOL * _Nonnull stop) {
        [TFDataCaptureManager.sharedInstance.capturer updateWCDataItem:item withItemId:item.itemId];
    }];
}

- (void)generateCompletion {
    [TFDataCaptureManager.sharedInstance.capturer reciveDataComplate];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
